Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Recaptcha fields in more forms #365

Merged
merged 4 commits into from
Jun 27, 2019
Merged

Recaptcha fields in more forms #365

merged 4 commits into from
Jun 27, 2019

Conversation

iambibhas
Copy link
Contributor

Fixes #191 and #199.

@@ -172,6 +172,8 @@ def reset():
# User wants to reset password
# Ask for username or email, verify it, and send a reset code
form = PasswordResetRequestForm()
if not (current_app.config.get('RECAPTCHA_PUBLIC_KEY') and current_app.config.get('RECAPTCHA_PRIVATE_KEY')):
del form.recaptcha
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the recaptcha field name is recaptcha. I'll push an update to remove any recaptcha field instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine because the field is defined in the same repo. However, this will need to be done in all forms that use the Recaptcha field, so do this instead:

Subclass Form into RecaptchaForm and add the field. Forms that need it can inherit from it. The position of the field in the form is no longer relevant when it's invisible. In the __init__ constructor, remove the field if the config values are not present. This can be done in a new file named lastuser_oauth/forms/recaptcha.py.

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from flask_wtf import RecaptchaField
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add this field to Baseframe. We shouldn't be importing anything from flask_wtf

Copy link
Member

@jace jace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a bunch of single comments instead of review comments.

@jace jace merged commit 668b6a7 into master Jun 27, 2019
@jace jace deleted the recaptcha-fields branch June 27, 2019 17:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reset form should include Recaptcha
2 participants